<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>eventloop事件机制1230429(下)</title>
</head>
<body>
    <script>
        //前端巅峰人才交流群私信我
        setTimeout(function () { console.log(1) }, 0);
        new Promise(function (resolve, reject) {
            console.log(2); //1
            //  resolve();
             setTimeout(function(){resolve()},0)
        }).then(function () {
            console.log(3)
        }).then(function () { console.log(4) });
        process.nextTick(function () { console.log(5) });
        console.log(6); //2
        //script(主程序代码)—>process.nextTick—>Promises...
        //——>setTimeout——>setInterval——>setImmediate——> I/O——>UI rendering
        // 2 6 5  3 4 1
        // 2 6 5 1 3 4
        
    
        
    </script>
</body>
</html>